<template>
  <div>
    <el-dialog
      title="仪器借出登记"
      :visible.sync="approveVisible"
      width="50%"
      center
    >
      <div>
        <div class="install-title">仪器借出信息</div>
        <el-form :data="stuData" v-loading="loading" label-width="130px">
          <el-row :gutter="12">
            <el-col :span="12">
              <el-form-item prop="deviceId" label="仪器名称:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.deviceId"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="name" label="承借方名称:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.name"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="contactUser" label="承借方联系人:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.contactUser"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="start" label="借用日期:">
                <el-date-picker
                  :disabled="isLook"
                  style="width: 70%"
                  v-model="installForm.start"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="end" label="归还日期:">
                <el-date-picker
                  :disabled="isLook"
                  style="width: 70%"
                  v-model="installForm.end"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="approvalDep" label="审批部门:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.approvalDep"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="approvalUser" label="审批人:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.approvalUser"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="approvalTime" label="审批时间:">
                <el-date-picker
                  :disabled="isLook"
                  style="width: 70%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  v-model="installForm.approvalTime"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item prop="approvalOpinion" label="审批意见:">
                <el-input
                  :disabled="isLook"
                  v-model="installForm.approvalOpinion"
                  style="width: 70%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="approveVisible = false">取消</el-button>
        <el-button type="primary" @click="confirmTransfer">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import * as List from "@/api/List";
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["stuData", "loading"]),
  },
  data() {
    return {
      installForm: {},
      visible: false,
      approveVisible: false,
      isLook: false,
    };
  },
  methods: {
    confirmTransfer() {
      const {
        deviceId,
        name,
        contactUser,
        start,
        end,
        approvalDep,
        approvalUser,
        approvalTime,
        approvalOpinion,
      } = this.installForm;
      const data = {
        deviceId: this.installForm.deviceId,
        name: this.installForm.name,
        contactUser: this.installForm.contactUser,
        start: this.installForm.start,
        end: this.installForm.end,
        approvalUser:this.installForm.approvalUser,
        approvalDep: this.installForm.approvalDep,
        naapprovalUserme: this.installForm.naapprovalUserme,
        approvalTime: this.installForm.approvalTime,
        approvalOpinion: this.installForm.approvalOpinion,
      };
      List.Loanregistration(data).then((res) => {
        if (res.code === 200) {
          console.log(res.code);
          this.$notify({
            title: "成功",
            message: res.message,
            type: "success",
          });
          this.approveVisible = false;
        } else {
          this.$notify({
            title: "失败",
            message: res.message,
            type: "error",
          });
          this.approveVisible = false;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.install-title {
  display: flex;
  align-items: center;
  line-height: 30px;
  padding-left: 20px;
  color: #fff;
  background-color: #d7dae2;
  justify-content: flex-start;
  margin-bottom: 10px;
}
.delete {
  width: 10px;
  height: 10px;
  position: relative;
  top: -10px;
  cursor: pointer;
}
::v-deep .el-upload-list {
  width: 100px;
  display: flex;
  margin: 10px 10px;
}
::v-deep .el-upload-list > li {
  margin: 10px 10px;
}
::v-deep.el-upload-list__item {
  margin: 10px 10px;
}
::v-deep.el-upload-list--picture .el-upload-list__item {
  margin: 10px 10px !important;
}
.user-info-head {
  position: relative;
  display: inline-block;
  height: 120px;
}

::v-deep.avatar-upload-preview {
  width: 400px;
  border-radius: 0%;
  height: 400px;
  > img {
    transform: translateX(0);
  }
}
.user-info-head:hover:after {
  content: "+";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  color: #eee;
  background: rgba(0, 0, 0, 0.5);
  font-size: 24px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: pointer;
  line-height: 110px;
  border-radius: 50%;
}
</style>